package com.mars.push.core.repository;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;

import java.io.Serializable;
import java.util.Collection;
import java.util.List;
import java.util.Map;

/**
 * <b>功能描述:</b>
 * <p>
 * // 通用DAO接口
 * </p>
 *
 * @author huangch
 * @since 1.0
 */
public abstract class BaseDAO<T> {

    @Autowired
    private BaseMapper<T> baseMapper;

    public int insert(T entity) {
        return baseMapper.insert(entity);
    }

    public int deleteById(Serializable id) {
        return baseMapper.deleteById(id);
    }

    public int deleteByMap(@Param("cm") Map<String, Object> columnMap) {
        return baseMapper.deleteByMap(columnMap);
    }

    public int delete(@Param("ew") Wrapper<T> wrapper) {
        return baseMapper.delete(wrapper);
    }

    public int deleteBatchIds(@Param("coll") Collection<? extends Serializable> idList) {
        return baseMapper.deleteBatchIds(idList);
    }

    public int updateById(@Param("et") T entity) {
        return baseMapper.updateById(entity);
    }

    public int update(@Param("et") T entity, @Param("ew") Wrapper<T> updateWrapper) {
        return baseMapper.update(entity, updateWrapper);
    }

    public T selectById(Serializable id) {
        return (T) baseMapper.selectById(id);
    }

    public List<T> selectBatchIds(@Param("coll") Collection<? extends Serializable> idList) {
        return baseMapper.selectBatchIds(idList);
    }

    public List<T> selectByMap(@Param("cm") Map<String, Object> columnMap) {
        return baseMapper.selectByMap(columnMap);
    }

    public T selectOne(@Param("ew") Wrapper<T> queryWrapper) {
        return (T) baseMapper.selectOne(queryWrapper);
    }

    public Integer selectCount(@Param("ew") Wrapper<T> queryWrapper) {
        return baseMapper.selectCount(queryWrapper);
    }

    public List<T> selectList(@Param("ew") Wrapper<T> queryWrapper) {
        return baseMapper.selectList(queryWrapper);
    }

    public List<Map<String, Object>> selectMaps(@Param("ew") Wrapper<T> queryWrapper) {
        return baseMapper.selectMaps(queryWrapper);
    }

    public List<Object> selectObjs(@Param("ew") Wrapper<T> queryWrapper) {
        return baseMapper.selectObjs(queryWrapper);
    }

    public IPage<T> selectPage(IPage<T> page, @Param("ew") Wrapper<T> queryWrapper) {
        return baseMapper.selectPage(page, queryWrapper);
    }

    public IPage<Map<String, Object>> selectMapsPage(IPage<T> page, @Param("ew") Wrapper<T> queryWrapper) {
        return baseMapper.selectMapsPage(page, queryWrapper);
    }
}
